//
//  WebSocketMessageResult.swift
//  JiaoZiTaxi
//
//  Created by Hu Gang on 2022/11/14.
//

import Foundation

// MARK: - Message

struct WebSocketMessageBaseResult : Codable {
    let cmd, content: String?
    let from: String?
    let to, type: String?
}

struct WebSocketMessageTextResult: Codable {
  let avatar: String
  let cmd, content: String?
  let contents: [TextContent]
  let detectionID, endLat, endLon, endTimestamp: Int
  let from: String?
  let map, me: Bool
  let mydistance: Int
  let name, peopleID: String
  let price: Int
  let receiverJSON: String?
  let renshu: Int
  let roomID: String
  let sended, shijirenshu, startLat, startLon: Int
  let startTimestamp: Int
  let to, type: String?
  let updated: String
  let phraseCode: String?

  enum CodingKeys: String, CodingKey {
    case avatar, cmd, content, contents
    case detectionID = "detectionId"
    case endLat = "end_lat"
    case endLon = "end_lon"
    case endTimestamp = "end_timestamp"
    case from, map, me, mydistance, name
    case peopleID = "peopleId"
    case price, receiverJSON, renshu
    case roomID = "roomId"
    case sended, shijirenshu
    case startLat = "start_lat"
    case startLon = "start_lon"
    case startTimestamp = "start_timestamp"
    case to, type, updated
    case phraseCode = "phrasecode"
  }
}

// MARK: - Content
struct TextContent: Codable {
  let id, text, type: String
}

struct WebSocketMessageMediaResult: Codable {
    let avatar: String
    let cmd, content: String?
    let contents: [MediaContent]
    let detectionID, endLat, endLon, endTimestamp: Int
    let from: String?
    let map, me: Bool
    let mydistance: Int
    let name, peopleID: String
    let price: Int
    let receiverJSON: String?
    let renshu: Int
    let roomID: String
    let sended, shijirenshu, startLat, startLon: Int
    let startTimestamp: Int
    let to, type: String?
    let updated: String

    enum CodingKeys: String, CodingKey {
        case avatar, cmd, content, contents
        case detectionID = "detectionId"
        case endLat = "end_lat"
        case endLon = "end_lon"
        case endTimestamp = "end_timestamp"
        case from, map, me, mydistance, name
        case peopleID = "peopleId"
        case price, receiverJSON, renshu
        case roomID = "roomId"
        case sended, shijirenshu
        case startLat = "start_lat"
        case startLon = "start_lon"
        case startTimestamp = "start_timestamp"
        case to, type, updated
    }
}

struct MediaContent: Codable {
    let id, text, type,url: String
}
